const { model } = require('mongoose');
const { getAdmins, freezeAdmins, exposureFreezeAdmins, updatePassword } = require('../dao/adminsDao')

module.exports.getAdmins = async function (params) {
    if (params.searchInput) {
        const data = await getAdmins(params);
        return {
            message: '获取所有普通管理员数据成功',
            status: 1,
            data
        }
    } else {
        const result = await getAdmins(params);

        //把所有学生数据返回给前端，让前端可以有数据渲染页面
        return {
            message: '获取所有普通管理员数据成功',
            status: 1,
            data: result
        }
    }

}

module.exports.freezeAdmins = async function (_id) {
    const result = await freezeAdmins(_id);

    if (result.ok) {
        return {
            status: 1,
            message: '冻结成功',
            data: result
        }
    } else {
        return {
            status: 1,
            message: '冻结失败',
        }
    }
}
module.exports.exposureFreezeAdmins = async function (_id) {
    const result = await exposureFreezeAdmins(_id);
    if (result.ok) {
        return {
            status: 1,
            message: '解除冻结成功',
            data: result
        }
    } else {
        return {
            status: 1,
            message: '解除冻结失败',
        }
    }
}

module.exports.updatePassword = async function (params) {
    const result = await updatePassword(params);
    if (result.ok) {
        return {
            message: '修改成功',
            status: 1,
            data: result
        }
    }
}